<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改卖盘池</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.css"
	rel="stylesheet" type="text/css">

<link
	href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css"
	id="style_components" rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/plugins.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/layout.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css"
	rel="stylesheet" type="text/css" id="style_color">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/custom.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/common.css"
	rel="stylesheet" type="text/css">



<link rel="shortcut icon"
	href="${request.getContextPath()}/Public/favicon.ico">
<!--[if lt IE 9]>
<script src="${request.getContextPath()}/Public/assets/global/plugins/respond.min.js"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-validation/js/jquery.validate.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-validation/js/localization/messages_zh.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js"
	type="text/javascript"></script>

<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.sparkline.min.js"
	type="text/javascript"></script>

<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"
	type="text/javascript"></script>

<script
	src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js"
	type="text/javascript"></script>

<!-- select2控件 -->
<script type="text/javascript"
	src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.js"></script>
<script type="text/javascript"
	src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2_locale_zh-CN.js"></script>
	<!-- 数字小数点后两位工具类 -->
<script type="text/javascript" src="${request.getContextPath()}/Public/js/common/util.js"></script>
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.css"
	rel="stylesheet" type="text/css">

</head>
<body class="page-header-top-fixed">
	<div class="page-header">
		<!--头部开始-->
		<#include "/include/top.html" />
		<!-- 头部信息结束 -->

		<!-- 头部菜单开始 -->
		<#include "/include/top_menu.html" />
		<!-- 头部菜单结束 -->
	</div>
	<!-- END HEADER -->
	<div class="page-container">
		<div class="page-content">
			<div class="container-fluid">
				<!-- 当前位置提示开始 -->
				<ul class="page-breadcrumb breadcrumb">
					<li><a href="#">首页</a><i class="fa fa-circle"></i>
					<li class="active">撮合管理<i class="fa fa-circle"></i>
					<li class="active">修改报盘
				</ul>
				<div class="row margin-top-10">
					<div class="col-md-12">
						<div class="portlet light bordered">
							<form class="form-horizontal" id="dataForm">

								<input type="hidden" id="sellId" name="poolId" value="${pool.poolId!}"> 
								<input type="hidden" id="poolType" name="poolType" value="${pool.poolType!}">
								<input type="hidden" id="high"  value="${high}"/>
								<input type="hidden" id="low"  value="${low}"/>
								<!-- 摩擦摩擦修改报盘 -->
								<input type="hidden" id="moca" name="moca" value="moca"/>
								
								<div class="form-group">
									<label class="col-sm-2 control-label">类型：</label>
									<div class="col-sm-2">
										<input type="hidden" id="priceType" name="priceType" value="${pool.priceType}">
										<select class="form-control"  style="width: 235px; height: 34px;"  disabled="disabled"> 
											<option value="0" <#if pool.priceType == 0>selected</#if>> 实价 </option>
									     	<option value="1" <#if pool.priceType == 1>selected</#if>> 升贴水  </option>
										</select>

									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-2 control-label">库存：</label>
									<div class="col-sm-2">
										<input type="text" class="form-control" id="quantity" name="quantity" value="${pool.quantity}" style="width: 235px; height: 34px;"> 
										<span id="s1" style="color: red"></span>
									</div>
								</div>


								<div class="form-group">
									<label class="col-sm-2 control-label">价格：</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="price" name="price" value="${pool.price}"
											style="width: 235px; height: 34px;"  onblur="checkPrice()"> <span id="s2"
											style="color: red"></span>
											<span id="ERROR1" style="display:none;color: red;font-size: 12px;"">实价不能高于最高报盘价</span>
								        	<span id="ERROR2" style="display:none;color: red;font-size: 12px;"">实价不能低于最低报盘价</span>
									</div>
								</div>


								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-10">
										<button id="notSavetButton" type="button"
											onclick="javascript :history.back(-1);"
											class="btn  green pull-left">
											返回 <i class="m-icon-swapright m-icon-white"></i>
										</button>
										<button type="button" id="savetButton"
											class="btn green pull-center">
											提交<i class="m-icon-swapright m-icon-white"></i>
										</button>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 底部开始 -->
	<#include "/include/foot.html" />
	<!-- 底部结束 -->
</body>
<script>
	
	jQuery(document).ready(function() {
		//如果省不为空，则初始化仓库
		if ($('#wareProvince').val() != null) {
			$("#wareId").append("<option value='"+$("#wareIds").val()+"'>" + $("#wareName").val() + "</option>");
		}
	   
	   Metronic.init(); // init metronic core componets
	   Layout.init(); // init layout
		//小数点后两位check
		checkNum_2($('#price'));
	    checkNum5($('#quantity'));
	});
	recordDate();
	//初始化日期
	function recordDate() {
		var nowDate = new Date();
        //$('#date-picker').attr("date-date",nowDate.getFullYear()+"/"+parseInt(nowDate.getMonth()+1)+"/"+nowDate.getDate());
        $('.date-picker').datepicker({
    	    autoclose: true	   
    	});
        
        
	}
	
	$("#savetButton").bind("click",function(){
		//实价校验
		if($("#ERROR1").css("display") == "inline"){
			return false;
		}
		if($("#ERROR2").css("display") == "inline"){
			return false;
		}
		
		var  num=/^[0-9]+([.]{1}[0-9]+){0,1}$/;
		
		var  priceType_a=$("#priceType").val();
		var  poolType=$("#poolType").val();	
		var quantity=$("#quantity").val();
		var price=$("#price").val();
		
		if (!num.test(quantity) ||  quantity<=0){
		
			$("#s1").html("库存必须大于0的数字");
			return ;
			
		}
		
		
		if(poolType==1){
		if(priceType_a==0){
			if(price>${pool.price}){
				$("#s2").html("对不起 ，不允许涨价!");
				return ;
			}	
		}else if(priceType_a==1){
			if(priceType_a==${pool.priceType} && price>${pool.price} ){
				$("#s2").html("对不起 ，不允许涨价!");
				return ;
				}else if(${pool.priceType}==2){
					$("#s2").html("对不起 ，不允许涨价!");
					return ;
				}
			}else if(priceType_a==2){
			if(priceType_a==${pool.priceType} && price<${pool.price} ){
				$("#s2").html("对不起 ，不允许涨价!");
				return ;
				}
		}
	}
	if(poolType==2){
		if(priceType_a==0){
			if(price<${pool.price}){
				$("#s2").html("对不起 ，不允许降价!");
				return ;
			}	
		}else if(priceType_a==1){
			if(priceType_a==${pool.priceType} && price<${pool.price} ){
				$("#s2").html("对不起 ，不允许降价!");
				return ;
				}else if (${pool.priceType}==2){
					$("#s2").html("对不起 ，不允许降价!");
					   return ;
							
						}
			}else if (priceType_a==2){
				if(priceType_a==${pool.priceType} && price>${pool.price} ){
					$("#s2").html("对不起 ，不允许降价!");
				 return ;
				}
				
			}
			
	}
		
		
		
		$.ajax({
			url : "${request.getContextPath()}/PoolManage/updatePool.do",
			type : "post",
			dataType:"json",
			async: false,
			data : $("#dataForm").serialize(),
			success : function(result) {
			   if(result.code=="success"){
				CommonUtils.succModal2("系统提示",
						result.msg,"${request.getContextPath()}/business/index.do");
					
				}else if(result.code=="error"){
					CommonUtils.succModal2("系统提示",
							result.msg);
		   		}
			   }
		});
	});
	
	
	//实价与交易指导价进行对比 
	function checkPrice(){
		//数字强转为int类型 
		var price = parseInt($("#price").val());
		//最高价
		var high = parseInt($("#high").val());
		//最低价
		var low = parseInt($("#low").val());
		if($("#priceType").val() == 0){
			if(price > high){
				$("#ERROR2").css("display","none");
				$("#ERROR1").css("display","inline");
			}else if(price < low){
				$("#ERROR1").css("display","none");
				$("#ERROR2").css("display","inline");
			}else{
				$("#ERROR1").css("display","none");
				$("#ERROR2").css("display","none");
			}	
		}
		if($("#priceType").val() == 1){
				$("#ERROR1").css("display","none");
				$("#ERROR2").css("display","none");
		}
		if($("#priceType").val() == 2){
				$("#ERROR1").css("display","none");
				$("#ERROR2").css("display","none");
		}
	}

</script>
</html>

